package com.zzzy.sys.controller;

import com.zzzy.common.vo.AjaxResult;
import com.zzzy.common.vo.PageResult;
import com.zzzy.sys.service.UserLoginLogService;
import com.zzzy.sys.vo.log.UserLoginLogPageReq;
import com.zzzy.sys.vo.log.UserLoginLogRes;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springdoc.api.annotations.ParameterObject;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

@Tag(name = "用户登录日志", description = "sys005")
@Validated
@RestController
@RequestMapping("/system/loginLog")
public class UserLoginLogController {

    @Resource
    private UserLoginLogService userLoginLogService;

    @Operation(summary = "分页列表")
    @GetMapping(value = "/page")
    @PreAuthorize("@pvs.hasPermission('system:loginLog:page')")
    public AjaxResult<PageResult<UserLoginLogRes>> page(@Valid @ParameterObject UserLoginLogPageReq queryReq) {
        PageResult<UserLoginLogRes> userLoginLogPage = userLoginLogService.getUserLoginLogPage(queryReq);
        return AjaxResult.success(userLoginLogPage);
    }

}
